﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Model;
public partial class OrderPage : System.Web.UI.Page
{
    private Order order = new Order();
    private static IList<OrderInfo> orders;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            orders = order.GetOrders(Profile.UserName);
            this.OrderView.DataSource = orders;
            OrderView.DataBind();
        }
    }

    protected void OrderView_DeleteCommand(object source, DataGridCommandEventArgs e)
    {
        try
        {
            order.CancelOrder(orders[e.Item.ItemIndex].OrderId);
            Response.Write("<script>alert('撤销订单成功')</script>");
            orders = order.GetOrders(Profile.UserName);
            this.OrderView.DataSource = orders;
            OrderView.DataBind();

        }
        catch (ApplicationException ex)
        {
            Response.Write("<script>alert('撤销订单失败: " + ex.Message + "')</script>");
        }
        
    }
}